<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1 style="text-align: center;color: aquamarine;">表达式与运算符</h1>
    <script>
        // 算数运算符
        let sum1 = 1 + 9
        console.log(sum1)
        let sum2 = 9 - 1
        console.log(sum2)
        let sum3 = 2 * 2
        console.log(sum3)
        let sum4 = 9 / 2
        console.log(sum4)
        let sum5 = 9 % 5
        console.log(sum5)

        //比较运算符
        let bj1 = 5 > 6
        console.log(bj1)
        let bj2 = 5 < 6
        console.log(bj2)
        let bj3 = 5 >= 6
        console.log(bj3)
        let bj4 = 5 <= 6
        console.log(bj4)
        let bj5 = 5 == "5"
        console.log(bj5)
        let bj6 = 5 ==="5"
        console.log(bj6)
        let bj7 = 5 !="5"
        console.log(bj7)
        let bj8 = 5 !== "5"
        console.log(bj8)

        //逻辑运算符
        let lj1 = (5 > 4) && (5 > 6) 
        console.log(lj1)
        let lj2 = (5 > 4) || (5 > 6)
        console.log(lj2)
        let lj3 = !(5 > 4)
        console.log(lj3)

        let res1 = "" || "s"
        console.log(res1)



        //循环与分支
        let x = 1
        if(x = 1){
            console.log("true")
        }else if(x = 0){
            console.log("false")
        }else {
            console.log("数据错误: ",x)
        }

        let arr = ["1","2","3","4","5","6","7","8"]
        let arr1 = new Array("A","B","C","D","E","F")

        for (let i = arr.length - 1 ; i >= 0 ; i--){
            console.log(arr[i])
        }

        let n = arr1.length - 1
        while(n >= 0){
            console.log(arr1[n])
            n--
        }


        //函数

        function sum(x,y){
            return x + y
        }
        function le (x,y){
            return x-y
        }
        function cw(x,y){
            return x * y
        }

        console.log(sum(2,4))
        console.log(cw(3,4))

        function fz(x,y,func){
            return func(x,y)
        }
        console.log(fz(3,6,le))
        console.log(fz(9,2,cw))

        console.log(fz(8,8,(x,y)=>{
            return x ** y
        }))
    </script>
</body>
</html>